#coding:utf-8

""" data file parser.
    for every data file, parser will return result:
    
        {'func1': [{'arg1':obj1, 'arg2':obj2}, {'arg1':obj3, 'arg2':obj4}]
        ,'func2': [{'arg':obj}]
        ,'func3': [{'arg1':obj1, 'arg2':obj2}, {'arg1':obj3, 'arg2':obj4}]
        }
"""

import os

def parse_data(paths):
    for path in paths:
        ext = os.path.splitext(path)[1]
        if ext == '.xml':
            import usexml
            parse_call = usexml.parse_xml_data
        elif ext == '.yaml':
            import useyaml
            parse_call = useyaml.parse_yaml_data
        else:
            continue
        return parse_call(path)